﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;

using IBApi;

namespace IBRx {
	public class AccountAndPortfolio : IBResponse { }

	public class UpdateAccountValue : AccountAndPortfolio {
		public string Key { get; private set; }
		public string Value { get; private set; }
		public string Currency { get; private set; }
		public string AccountName { get; private set; }

		[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
		public UpdateAccountValue(string key, string value, string currency, string accountName) {
			this.Key = key;
			this.Value = value;
			this.Currency = currency;
			this.AccountName = accountName;
		}
	}

	public class UpdatePortfolio : AccountAndPortfolio {
		public Contract Contract { get; private set; }
		public int Position { get; private set; }
		public double MarketPrice { get; private set; }
		public double MarketValue { get; private set; }
		public double AverageCost { get; private set; }
		public double UnrealisedPNL { get; private set; }
		public double RealisedPNL { get; private set; }
		public string AccountName { get; private set; }

		[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
		public UpdatePortfolio(Contract contract, int position, double marketPrice, double marketValue, double averageCost, double unrealisedPNL, double realisedPNL, string accountName) {
			this.Contract = contract;
			this.Position = position;
			this.MarketPrice = marketPrice;
			this.MarketValue = marketValue;
			this.AverageCost = averageCost;
			this.UnrealisedPNL = unrealisedPNL;
			this.RealisedPNL = realisedPNL;
			this.AccountName = accountName;
		}
	}

	public class UpdateAccountTime : AccountAndPortfolio {
		public string Timestamp { get; private set; }

		[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
		public UpdateAccountTime(string timestamp) {
			this.Timestamp = timestamp;
		}
	}

	public class AccountDownloadEnd : AccountAndPortfolio {
		public string Account { get; private set; }

		[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
		public AccountDownloadEnd(string account) {
			this.Account = account;
		}
	}

	public class PositionEvent : AccountAndPortfolio {
		public string Account { get; private set; }
		public Contract Contract { get; private set; }
		public int Pos { get; private set; }
		public double AvgCost { get; private set; }

		public PositionEvent(string account, Contract contract, int pos, double avgCost) {
			this.Account = account;
			this.Contract = contract;
			this.Pos = pos;
			this.AvgCost = avgCost;
		}
	}
}
